@echo off
setlocal enabledelayedexpansion

rem Please execute this script from the root of the project's directory.

for /f %%d in ('dir /b examples') do (
    for /f %%f in ('dir /b examples\%%d') do (
        cargo +nightly build --release --no-default-features --target=wasm32-unknown-unknown --manifest-path examples\%%d\%%f\Cargo.toml
        if !errorlevel! neq 0 (
            exit /b %errorlevel%
        )
        cargo +nightly test --manifest-path examples\%%d\%%f\Cargo.toml
        if !errorlevel! neq 0 (
            exit /b %errorlevel%
        )
        cargo +nightly run --package abi-gen --manifest-path examples\%%d\%%f\Cargo.toml
        if !errorlevel! neq 0 (
            exit /b %errorlevel%
        )
        cargo +nightly build --release --no-default-features --features "gm" --target=wasm32-unknown-unknown --manifest-path examples\%%d\%%f\Cargo.toml
        if !errorlevel! neq 0 (
            exit /b %errorlevel%
        )
    )
)
